/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dinotrack.struts;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author alquad
 */
public class ControlPanelForm extends org.apache.struts.action.ActionForm {
    
    
    /**
     *
     */
    public ControlPanelForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        
        HttpSession session = request.getSession(true); 
        if(session.getAttribute("USER")== null) { 
            errors.add("userSession",new ActionMessage("errors.session.user"));
        }
        System.out.println("############### VALIDATE METHOD - SESSION USER: "+session.getAttribute("USER"));
        
        return errors;
    }
}
